#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#

# -*- mode: python; -*-

import platform
Import('AgentEnv')
env = AgentEnv.Clone()

except_env = env.Clone()
cflags = except_env['CCFLAGS']
if '-fno-exceptions' in cflags:
   cflags.remove('-fno-exceptions')
except_env.Replace(CCFLAGS=cflags)

SandeshGenFiles = env.SandeshGenCpp('agent.sandesh')
SandeshGenFiles += env.SandeshGenCpp('agent_profile.sandesh')
SandeshGenFiles += env.SandeshGenCpp('multicast.sandesh')
SandeshGenSrcs = env.ExtractCpp(SandeshGenFiles)
sandesh_objs = AgentEnv.BuildExceptionCppObj(env, SandeshGenSrcs)
optional_objs = []

if GetOption('with_libvirt'):
    optional_objs.append(except_env.Object('libvirt_instance_adapter.cc'))

if platform.system() == 'Windows':
    os_specific_src = [
        'windows/windows_net_interface.cc',
        'windows/interface_params.cc',
        'windows/instance_task_stub.cc',
    ]
else:
    os_specific_src = ['nix/interface_params.cc', 'instance_task.cc']

vnswoperdb = env.Library('vnswoperdb',
                         sandesh_objs +
                         optional_objs +
                         ['agent_sandesh.cc',
                          'agent_path.cc',
                          'agent_profile.cc',
                          'agent_route.cc',
                          'agent_route_resync.cc',
                          'agent_route_walker.cc',
                          'bgp_as_service.cc',
                          'bgp_router.cc',
                          'bridge_route.cc',
                          'bridge_domain.cc',
                          'config_manager.cc',
                          'crypt_tunnel.cc',
                          'ecmp.cc',
                          'evpn_route.cc',
                          'forwarding_class.cc',
                          'global_qos_config.cc',
                          'global_system_config.cc',
                          'global_vrouter.cc',
                          'health_check.cc',
                          'ifmap_dependency_manager.cc',
                          'inet_interface.cc',
                          'inet4_multicast_route.cc',
                          'inet_unicast_route.cc',
                          'interface.cc',
                          'logical_interface.cc',
                          'metadata_ip.cc',
                          'mirror_table.cc',
                          'mpls.cc',
                          'multicast.cc',
                          except_env.Object('instance_manager.cc'),
                          except_env.Object('docker_instance_adapter.cc'),
                          except_env.Object('netns_instance_adapter.cc'),
                          'nexthop.cc',
                          'operdb_init.cc',
                          'path_preference.cc',
                          'peer.cc',
                          'physical_device.cc',
                          'physical_device_vn.cc',
                          'physical_interface.cc',
                          'project_config.cc',
                          'qos_config.cc',
                          'qos_queue.cc',
                          'remote_physical_interface.cc',
                          'route_leak.cc',
                          'security_logging_object.cc',
                          'service_instance.cc',
                          'sg.cc',
                          'tag.cc',
                          'tsn_elector.cc',
                          'vm.cc',
                          'vm_interface.cc',
                          'vm_interface_config.cc',
                          'vm_interface_request.cc',
                          'vm_interface_utils.cc',
                          'vn.cc',
                          'vrf.cc',
                          'vrf_assign.cc',
                          'vrouter.cc',
                          'vxlan.cc',
                          'vxlan_routing_manager.cc',
                          'multicast_policy.cc',
                          os_specific_src,
                         ])
subdirs = ['test']
for dir in subdirs:
    env.SConscript(dir + '/SConscript', exports='AgentEnv', duplicate=0)
